package dk.pun.aot.shared.character;

public class SkillRankVerifier {

	private static final int MIN_VALUE = 1;
	private static final int MAX_VALUE = 30;
	
	public static int verify(int skillRank) throws IllegalArgumentException {
		if (skillRank < MIN_VALUE) {
			throw new IllegalArgumentException("Minimum value is " + String.valueOf(MIN_VALUE));
		}
		if (skillRank > MAX_VALUE) {
			throw new IllegalArgumentException("Maximum value is " + String.valueOf(MAX_VALUE));
		}
		return skillRank;
	}

	public static int verify(String skillRank) throws IllegalArgumentException {
		if (skillRank.isEmpty()) {
			throw new IllegalArgumentException("No score entered.");
		}
		int qs;
		try {
			qs = Integer.valueOf(skillRank);
		} catch (NumberFormatException e) {
			throw new IllegalArgumentException("Must be a number.", e);
		}
		return SkillRankVerifier.verify(qs);
	}

}
